These functions substitute elements
throughout a tree of cons cells. (See Sequence
Functions, for the substitute function, which
works on just the top-level elements of a list.)
This function substitutes occurrences of old with new in tree, a tree of cons cells. It returns a substituted tree, which will be a copy except that it may share storage with the argument tree in parts where no substitutions occurred. The original tree is not modified. This function recurses on, and compares against old, both
cars andcdrs of the component cons cells. If old is itself a cons cell, then matching cells in the tree are substituted as usual without recursively substituting in that cell. Comparisons with old are done according to the specified test (eqlby default). The:keyfunction is applied to the elements of the tree but not to old.
This function is like
subst, except that it works by destructive modification (bysetcarorsetcdr) rather than copying.
The subst-if,
subst-if-not, nsubst-if, and
nsubst-if-not functions are defined similarly.
This function is like
subst, except that it takes an association list alist of old-new pairs. Each element of the tree (after applying the:keyfunction, if any), is compared with thecars of alist; if it matches, it is replaced by the correspondingcdr.